<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>LibCDS: /home/zsshen/Desktop/git-hub-code/C-Common-Data-Structures/include/container/stack.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">LibCDS
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('stack_8h.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">stack.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>The LIFO stack.  
<a href="#details">More...</a></p>

<p><a href="stack_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structStack.html">Stack</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The implementation for stack.  <a href="structStack.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:af968af8c43a6dda234dde1f746408d3a"><td class="memItemLeft" align="right" valign="top">typedef struct _StackData&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#af968af8c43a6dda234dde1f746408d3a">StackData</a></td></tr>
<tr class="memdesc:af968af8c43a6dda234dde1f746408d3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">StackData is the data type for the container private information.  <a href="#af968af8c43a6dda234dde1f746408d3a">More...</a><br/></td></tr>
<tr class="separator:af968af8c43a6dda234dde1f746408d3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a3049959ea474e0622db16c479c3eb217"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#a3049959ea474e0622db16c479c3eb217">StackInit</a> (<a class="el" href="structStack.html">Stack</a> **ppObj)</td></tr>
<tr class="memdesc:a3049959ea474e0622db16c479c3eb217"><td class="mdescLeft">&#160;</td><td class="mdescRight">The constructor for <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a>.  <a href="#a3049959ea474e0622db16c479c3eb217">More...</a><br/></td></tr>
<tr class="separator:a3049959ea474e0622db16c479c3eb217"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa3773552daf4b7a1d916f66ed689ee8f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#aa3773552daf4b7a1d916f66ed689ee8f">StackDeinit</a> (<a class="el" href="structStack.html">Stack</a> **ppObj)</td></tr>
<tr class="memdesc:aa3773552daf4b7a1d916f66ed689ee8f"><td class="mdescLeft">&#160;</td><td class="mdescRight">The destructor for <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a>.  <a href="#aa3773552daf4b7a1d916f66ed689ee8f">More...</a><br/></td></tr>
<tr class="separator:aa3773552daf4b7a1d916f66ed689ee8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1245bd0f5a05613512420b3255bcfa74"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#a1245bd0f5a05613512420b3255bcfa74">StackPush</a> (<a class="el" href="structStack.html">Stack</a> *self, Item item)</td></tr>
<tr class="memdesc:a1245bd0f5a05613512420b3255bcfa74"><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert an item to the top of the stack.  <a href="#a1245bd0f5a05613512420b3255bcfa74">More...</a><br/></td></tr>
<tr class="separator:a1245bd0f5a05613512420b3255bcfa74"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a612f324df336d05db3266421ee35ea39"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#a612f324df336d05db3266421ee35ea39">StackPop</a> (<a class="el" href="structStack.html">Stack</a> *self)</td></tr>
<tr class="memdesc:a612f324df336d05db3266421ee35ea39"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete item from top of the stack.  <a href="#a612f324df336d05db3266421ee35ea39">More...</a><br/></td></tr>
<tr class="separator:a612f324df336d05db3266421ee35ea39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4ac15dedfababd313e61132761b5ce3a"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#a4ac15dedfababd313e61132761b5ce3a">StackTop</a> (<a class="el" href="structStack.html">Stack</a> *self, Item *pItem)</td></tr>
<tr class="memdesc:a4ac15dedfababd313e61132761b5ce3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieve item from top of the stack.  <a href="#a4ac15dedfababd313e61132761b5ce3a">More...</a><br/></td></tr>
<tr class="separator:a4ac15dedfababd313e61132761b5ce3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af28cb452f15d021156d0bf5626ffd1e8"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#af28cb452f15d021156d0bf5626ffd1e8">StackSize</a> (<a class="el" href="structStack.html">Stack</a> *self)</td></tr>
<tr class="memdesc:af28cb452f15d021156d0bf5626ffd1e8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the number of stored items.  <a href="#af28cb452f15d021156d0bf5626ffd1e8">More...</a><br/></td></tr>
<tr class="separator:af28cb452f15d021156d0bf5626ffd1e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a45e7a4767c677ff44f39b5a6ed862076"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8h.html#a45e7a4767c677ff44f39b5a6ed862076">StackSetDestroy</a> (<a class="el" href="structStack.html">Stack</a> *self, void(*pFunc)(Item))</td></tr>
<tr class="memdesc:a45e7a4767c677ff44f39b5a6ed862076"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the custom item resource clean method.  <a href="#a45e7a4767c677ff44f39b5a6ed862076">More...</a><br/></td></tr>
<tr class="separator:a45e7a4767c677ff44f39b5a6ed862076"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The LIFO stack. </p>

<p>Definition in file <a class="el" href="stack_8h_source.html">stack.h</a>.</p>
</div><h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="af968af8c43a6dda234dde1f746408d3a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct _StackData <a class="el" href="stack_8h.html#af968af8c43a6dda234dde1f746408d3a">StackData</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>StackData is the data type for the container private information. </p>

<p>Definition at line <a class="el" href="stack_8h_source.html#l00011">11</a> of file <a class="el" href="stack_8h_source.html">stack.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a3049959ea474e0622db16c479c3eb217"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t StackInit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> **&#160;</td>
          <td class="paramname"><em>ppObj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The constructor for <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ppObj</td><td>The double pointer to the to be constructed stack</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for stack construction </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aa3773552daf4b7a1d916f66ed689ee8f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void StackDeinit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> **&#160;</td>
          <td class="paramname"><em>ppObj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The destructor for <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a>. </p>
<p>If the custom resource clean method is set, it also runs the clean method for all the items.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ppObj</td><td>The double pointer to the to be destructed stack </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a1245bd0f5a05613512420b3255bcfa74"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t StackPush </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item&#160;</td>
          <td class="paramname"><em>item</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Insert an item to the top of the stack. </p>
<p>This function inserts an item to the top of the stack with the corresponding stack size extension.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a> structure </td></tr>
    <tr><td class="paramname">item</td><td>The designated item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_NOMEM</td><td>Insufficient memory for stack extension </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a612f324df336d05db3266421ee35ea39"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t StackPop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete item from top of the stack. </p>
<p>This function deletes item from the top of the stack. If the custom resource clean method is set, it also runs the clean method for the deleted item.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Empty stack </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a4ac15dedfababd313e61132761b5ce3a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t StackTop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Item *&#160;</td>
          <td class="paramname"><em>pItem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Retrieve item from top of the stack. </p>
<p>This function retrieves item from the top of the stack. If the stack is not empty, the item is returned by the second parameter. Otherwise, the error code is returned and the second parameter is updated with NULL.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a> structure </td></tr>
    <tr><td class="paramname">pItem</td><td>The pointer to the returned item</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
    <tr><td class="paramname">ERR_IDX</td><td>Empty stack </td></tr>
    <tr><td class="paramname">ERR_GET</td><td>Invalid parameter to store returned item </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="af28cb452f15d021156d0bf5626ffd1e8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t StackSize </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the number of stored items. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a> structure</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of items </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a45e7a4767c677ff44f39b5a6ed862076"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t StackSetDestroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structStack.html">Stack</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void(*)(Item)&#160;</td>
          <td class="paramname"><em>pFunc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the custom item resource clean method. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>The pointer to <a class="el" href="structStack.html" title="The implementation for stack. ">Stack</a> structure </td></tr>
    <tr><td class="paramname">pFunc</td><td>The function pointer to the custom method</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">SUCC</td><td></td></tr>
    <tr><td class="paramname">ERR_NOINIT</td><td>Uninitialized container </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_e0f5f6345e438c73b9ae78ec2940718c.html">container</a></li><li class="navelem"><a class="el" href="stack_8h.html">stack.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
